<?php


abstract class BaseUser extends BaseObject  implements Persistent {


  const PEER = 'UserPeer';

	
	protected static $peer;

	
	protected $id;

	
	protected $username;

	
	protected $file;

	
	protected $email;

	
	protected $salt;

	
	protected $password;

	
	protected $remember;

	
	protected $url;

	
	protected $credential;

	
	protected $visible;

	
	protected $collPosts;

	
	private $lastPostCriteria = null;

	
	protected $collComments;

	
	private $lastCommentCriteria = null;

	
	protected $collUserI18ns;

	
	private $lastUserI18nCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

  
  protected $culture;

	
	public function __construct()
	{
		parent::__construct();
		$this->applyDefaultValues();
	}

	
	public function applyDefaultValues()
	{
		$this->file = '';
		$this->visible = 0;
	}

	
	public function getId()
	{
		return $this->id;
	}

	
	public function getUsername()
	{
		return $this->username;
	}

	
	public function getFile()
	{
		return $this->file;
	}

	
	public function getEmail()
	{
		return $this->email;
	}

	
	public function getSalt()
	{
		return $this->salt;
	}

	
	public function getPassword()
	{
		return $this->password;
	}

	
	public function getRemember()
	{
		return $this->remember;
	}

	
	public function getUrl()
	{
		return $this->url;
	}

	
	public function getCredential()
	{
		return $this->credential;
	}

	
	public function getVisible()
	{
		return $this->visible;
	}

	
	public function setId($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = UserPeer::ID;
		}

		return $this;
	} 
	
	public function setUsername($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->username !== $v) {
			$this->username = $v;
			$this->modifiedColumns[] = UserPeer::USERNAME;
		}

		return $this;
	} 
	
	public function setFile($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->file !== $v || $v === '') {
			$this->file = $v;
			$this->modifiedColumns[] = UserPeer::FILE;
		}

		return $this;
	} 
	
	public function setEmail($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->email !== $v) {
			$this->email = $v;
			$this->modifiedColumns[] = UserPeer::EMAIL;
		}

		return $this;
	} 
	
	public function setSalt($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->salt !== $v) {
			$this->salt = $v;
			$this->modifiedColumns[] = UserPeer::SALT;
		}

		return $this;
	} 
	
	public function setPassword($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->password !== $v) {
			$this->password = $v;
			$this->modifiedColumns[] = UserPeer::PASSWORD;
		}

		return $this;
	} 
	
	public function setRemember($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->remember !== $v) {
			$this->remember = $v;
			$this->modifiedColumns[] = UserPeer::REMEMBER;
		}

		return $this;
	} 
	
	public function setUrl($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->url !== $v) {
			$this->url = $v;
			$this->modifiedColumns[] = UserPeer::URL;
		}

		return $this;
	} 
	
	public function setCredential($v)
	{
		if ($v !== null) {
			$v = (string) $v;
		}

		if ($this->credential !== $v) {
			$this->credential = $v;
			$this->modifiedColumns[] = UserPeer::CREDENTIAL;
		}

		return $this;
	} 
	
	public function setVisible($v)
	{
		if ($v !== null) {
			$v = (int) $v;
		}

		if ($this->visible !== $v || $v === 0) {
			$this->visible = $v;
			$this->modifiedColumns[] = UserPeer::VISIBLE;
		}

		return $this;
	} 
	
	public function hasOnlyDefaultValues()
	{
						if (array_diff($this->modifiedColumns, array(UserPeer::FILE,UserPeer::VISIBLE))) {
				return false;
			}

			if ($this->file !== '') {
				return false;
			}

			if ($this->visible !== 0) {
				return false;
			}

				return true;
	} 
	
	public function hydrate($row, $startcol = 0, $rehydrate = false)
	{
		try {

			$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
			$this->username = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
			$this->file = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
			$this->email = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
			$this->salt = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
			$this->password = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
			$this->remember = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
			$this->url = ($row[$startcol + 7] !== null) ? (string) $row[$startcol + 7] : null;
			$this->credential = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
			$this->visible = ($row[$startcol + 9] !== null) ? (int) $row[$startcol + 9] : null;
			$this->resetModified();

			$this->setNew(false);

			if ($rehydrate) {
				$this->ensureConsistency();
			}

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating User object", $e);
		}
	}

	
	public function ensureConsistency()
	{

	} 
	
	public function reload($deep = false, PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("Cannot reload a deleted object.");
		}

		if ($this->isNew()) {
			throw new PropelException("Cannot reload an unsaved object.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_READ);
		}

				
		$stmt = UserPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
		$row = $stmt->fetch(PDO::FETCH_NUM);
		$stmt->closeCursor();
		if (!$row) {
			throw new PropelException('Cannot find matching row in the database to reload object values.');
		}
		$this->hydrate($row, 0, true); 
		if ($deep) {  
			$this->collPosts = null;
			$this->lastPostCriteria = null;

			$this->collComments = null;
			$this->lastCommentCriteria = null;

			$this->collUserI18ns = null;
			$this->lastUserI18nCriteria = null;

		} 	}

	
	public function delete(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			UserPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	public function save(PropelPDO $con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
		}
		
		$con->beginTransaction();
		try {
			$affectedRows = $this->doSave($con);
			$con->commit();
			UserPeer::addInstanceToPool($this);
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollBack();
			throw $e;
		}
	}

	
	protected function doSave(PropelPDO $con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;

			if ($this->isNew() ) {
				$this->modifiedColumns[] = UserPeer::ID;
			}

						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = UserPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += UserPeer::doUpdate($this, $con);
				}

				$this->resetModified(); 			}

			if ($this->collPosts !== null) {
				foreach ($this->collPosts as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collComments !== null) {
				foreach ($this->collComments as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			if ($this->collUserI18ns !== null) {
				foreach ($this->collUserI18ns as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;

		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = UserPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collPosts !== null) {
					foreach ($this->collPosts as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collComments !== null) {
					foreach ($this->collComments as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}

				if ($this->collUserI18ns !== null) {
					foreach ($this->collUserI18ns as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		$field = $this->getByPosition($pos);
		return $field;
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getUsername();
				break;
			case 2:
				return $this->getFile();
				break;
			case 3:
				return $this->getEmail();
				break;
			case 4:
				return $this->getSalt();
				break;
			case 5:
				return $this->getPassword();
				break;
			case 6:
				return $this->getRemember();
				break;
			case 7:
				return $this->getUrl();
				break;
			case 8:
				return $this->getCredential();
				break;
			case 9:
				return $this->getVisible();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
	{
		$keys = UserPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getUsername(),
			$keys[2] => $this->getFile(),
			$keys[3] => $this->getEmail(),
			$keys[4] => $this->getSalt(),
			$keys[5] => $this->getPassword(),
			$keys[6] => $this->getRemember(),
			$keys[7] => $this->getUrl(),
			$keys[8] => $this->getCredential(),
			$keys[9] => $this->getVisible(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = UserPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setUsername($value);
				break;
			case 2:
				$this->setFile($value);
				break;
			case 3:
				$this->setEmail($value);
				break;
			case 4:
				$this->setSalt($value);
				break;
			case 5:
				$this->setPassword($value);
				break;
			case 6:
				$this->setRemember($value);
				break;
			case 7:
				$this->setUrl($value);
				break;
			case 8:
				$this->setCredential($value);
				break;
			case 9:
				$this->setVisible($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = UserPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setUsername($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setFile($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setEmail($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setSalt($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setPassword($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setRemember($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setUrl($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCredential($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setVisible($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(UserPeer::DATABASE_NAME);

		if ($this->isColumnModified(UserPeer::ID)) $criteria->add(UserPeer::ID, $this->id);
		if ($this->isColumnModified(UserPeer::USERNAME)) $criteria->add(UserPeer::USERNAME, $this->username);
		if ($this->isColumnModified(UserPeer::FILE)) $criteria->add(UserPeer::FILE, $this->file);
		if ($this->isColumnModified(UserPeer::EMAIL)) $criteria->add(UserPeer::EMAIL, $this->email);
		if ($this->isColumnModified(UserPeer::SALT)) $criteria->add(UserPeer::SALT, $this->salt);
		if ($this->isColumnModified(UserPeer::PASSWORD)) $criteria->add(UserPeer::PASSWORD, $this->password);
		if ($this->isColumnModified(UserPeer::REMEMBER)) $criteria->add(UserPeer::REMEMBER, $this->remember);
		if ($this->isColumnModified(UserPeer::URL)) $criteria->add(UserPeer::URL, $this->url);
		if ($this->isColumnModified(UserPeer::CREDENTIAL)) $criteria->add(UserPeer::CREDENTIAL, $this->credential);
		if ($this->isColumnModified(UserPeer::VISIBLE)) $criteria->add(UserPeer::VISIBLE, $this->visible);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(UserPeer::DATABASE_NAME);

		$criteria->add(UserPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setUsername($this->username);

		$copyObj->setFile($this->file);

		$copyObj->setEmail($this->email);

		$copyObj->setSalt($this->salt);

		$copyObj->setPassword($this->password);

		$copyObj->setRemember($this->remember);

		$copyObj->setUrl($this->url);

		$copyObj->setCredential($this->credential);

		$copyObj->setVisible($this->visible);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach ($this->getPosts() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addPost($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getComments() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addComment($relObj->copy($deepCopy));
				}
			}

			foreach ($this->getUserI18ns() as $relObj) {
				if ($relObj !== $this) {  					$copyObj->addUserI18n($relObj->copy($deepCopy));
				}
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new UserPeer();
		}
		return self::$peer;
	}

	
	public function clearPosts()
	{
		$this->collPosts = null; 	}

	
	public function initPosts()
	{
		$this->collPosts = array();
	}

	
	public function getPosts($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collPosts === null) {
			if ($this->isNew()) {
			   $this->collPosts = array();
			} else {

				$criteria->add(PostPeer::USER_ID, $this->id);

				PostPeer::addSelectColumns($criteria);
				$this->collPosts = PostPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(PostPeer::USER_ID, $this->id);

				PostPeer::addSelectColumns($criteria);
				if (!isset($this->lastPostCriteria) || !$this->lastPostCriteria->equals($criteria)) {
					$this->collPosts = PostPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastPostCriteria = $criteria;
		return $this->collPosts;
	}

	
	public function countPosts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collPosts === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(PostPeer::USER_ID, $this->id);

				$count = PostPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(PostPeer::USER_ID, $this->id);

				if (!isset($this->lastPostCriteria) || !$this->lastPostCriteria->equals($criteria)) {
					$count = PostPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collPosts);
				}
			} else {
				$count = count($this->collPosts);
			}
		}
		$this->lastPostCriteria = $criteria;
		return $count;
	}

	
	public function addPost(Post $l)
	{
		if ($this->collPosts === null) {
			$this->initPosts();
		}
		if (!in_array($l, $this->collPosts, true)) { 			array_push($this->collPosts, $l);
			$l->setUser($this);
		}
	}

	
	public function clearComments()
	{
		$this->collComments = null; 	}

	
	public function initComments()
	{
		$this->collComments = array();
	}

	
	public function getComments($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collComments === null) {
			if ($this->isNew()) {
			   $this->collComments = array();
			} else {

				$criteria->add(CommentPeer::USER_ID, $this->id);

				CommentPeer::addSelectColumns($criteria);
				$this->collComments = CommentPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(CommentPeer::USER_ID, $this->id);

				CommentPeer::addSelectColumns($criteria);
				if (!isset($this->lastCommentCriteria) || !$this->lastCommentCriteria->equals($criteria)) {
					$this->collComments = CommentPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastCommentCriteria = $criteria;
		return $this->collComments;
	}

	
	public function countComments(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collComments === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(CommentPeer::USER_ID, $this->id);

				$count = CommentPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(CommentPeer::USER_ID, $this->id);

				if (!isset($this->lastCommentCriteria) || !$this->lastCommentCriteria->equals($criteria)) {
					$count = CommentPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collComments);
				}
			} else {
				$count = count($this->collComments);
			}
		}
		$this->lastCommentCriteria = $criteria;
		return $count;
	}

	
	public function addComment(Comment $l)
	{
		if ($this->collComments === null) {
			$this->initComments();
		}
		if (!in_array($l, $this->collComments, true)) { 			array_push($this->collComments, $l);
			$l->setUser($this);
		}
	}


	
	public function getCommentsJoinPost($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collComments === null) {
			if ($this->isNew()) {
				$this->collComments = array();
			} else {

				$criteria->add(CommentPeer::USER_ID, $this->id);

				$this->collComments = CommentPeer::doSelectJoinPost($criteria, $con, $join_behavior);
			}
		} else {
									
			$criteria->add(CommentPeer::USER_ID, $this->id);

			if (!isset($this->lastCommentCriteria) || !$this->lastCommentCriteria->equals($criteria)) {
				$this->collComments = CommentPeer::doSelectJoinPost($criteria, $con, $join_behavior);
			}
		}
		$this->lastCommentCriteria = $criteria;

		return $this->collComments;
	}

	
	public function clearUserI18ns()
	{
		$this->collUserI18ns = null; 	}

	
	public function initUserI18ns()
	{
		$this->collUserI18ns = array();
	}

	
	public function getUserI18ns($criteria = null, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collUserI18ns === null) {
			if ($this->isNew()) {
			   $this->collUserI18ns = array();
			} else {

				$criteria->add(UserI18nPeer::ID, $this->id);

				UserI18nPeer::addSelectColumns($criteria);
				$this->collUserI18ns = UserI18nPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(UserI18nPeer::ID, $this->id);

				UserI18nPeer::addSelectColumns($criteria);
				if (!isset($this->lastUserI18nCriteria) || !$this->lastUserI18nCriteria->equals($criteria)) {
					$this->collUserI18ns = UserI18nPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastUserI18nCriteria = $criteria;
		return $this->collUserI18ns;
	}

	
	public function countUserI18ns(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
	{
		if ($criteria === null) {
			$criteria = new Criteria(UserPeer::DATABASE_NAME);
		} else {
			$criteria = clone $criteria;
		}

		if ($distinct) {
			$criteria->setDistinct();
		}

		$count = null;

		if ($this->collUserI18ns === null) {
			if ($this->isNew()) {
				$count = 0;
			} else {

				$criteria->add(UserI18nPeer::ID, $this->id);

				$count = UserI18nPeer::doCount($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(UserI18nPeer::ID, $this->id);

				if (!isset($this->lastUserI18nCriteria) || !$this->lastUserI18nCriteria->equals($criteria)) {
					$count = UserI18nPeer::doCount($criteria, $con);
				} else {
					$count = count($this->collUserI18ns);
				}
			} else {
				$count = count($this->collUserI18ns);
			}
		}
		$this->lastUserI18nCriteria = $criteria;
		return $count;
	}

	
	public function addUserI18n(UserI18n $l)
	{
		if ($this->collUserI18ns === null) {
			$this->initUserI18ns();
		}
		if (!in_array($l, $this->collUserI18ns, true)) { 			array_push($this->collUserI18ns, $l);
			$l->setUser($this);
		}
	}

	
	public function clearAllReferences($deep = false)
	{
		if ($deep) {
			if ($this->collPosts) {
				foreach ((array) $this->collPosts as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collComments) {
				foreach ((array) $this->collComments as $o) {
					$o->clearAllReferences($deep);
				}
			}
			if ($this->collUserI18ns) {
				foreach ((array) $this->collUserI18ns as $o) {
					$o->clearAllReferences($deep);
				}
			}
		} 
		$this->collPosts = null;
		$this->collComments = null;
		$this->collUserI18ns = null;
	}


  
  public function getCulture()
  {
    return $this->culture;
  }

  
  public function setCulture($culture)
  {
    $this->culture = $culture;
  }

  public function getName($culture = null)
  {
    return $this->getCurrentUserI18n($culture)->getName();
  }

  public function setName($value, $culture = null)
  {
    $this->getCurrentUserI18n($culture)->setName($value);
  }

  public function getAbout($culture = null)
  {
    return $this->getCurrentUserI18n($culture)->getAbout();
  }

  public function setAbout($value, $culture = null)
  {
    $this->getCurrentUserI18n($culture)->setAbout($value);
  }

  protected $current_i18n = array();

  public function getCurrentUserI18n($culture = null)
  {
    if (is_null($culture))
    {
      $culture = is_null($this->culture) ? sfPropel::getDefaultCulture() : $this->culture;
    }

    if (!isset($this->current_i18n[$culture]))
    {
      $obj = UserI18nPeer::retrieveByPK($this->getId(), $culture);
      if ($obj)
      {
        $this->setUserI18nForCulture($obj, $culture);
      }
      else
      {
        $this->setUserI18nForCulture(new UserI18n(), $culture);
        $this->current_i18n[$culture]->setCulture($culture);
      }
    }

    return $this->current_i18n[$culture];
  }

  public function setUserI18nForCulture($object, $culture)
  {
    $this->current_i18n[$culture] = $object;
    $this->addUserI18n($object);
  }

} 